// 封装方法
const INFO_KEY = 'heizai_shopping_info'
const HISTORY_KEY = 'heizai_history_info'

// 获取信息
export const getInfo = () => {
  const result = localStorage.getItem(INFO_KEY)
  return result ? JSON.parse(result) : { token: '', userId: '' }
}

// 修改信息
export const setInfo = (info) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(info))
}

// 移除信息
export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

// 获取历史信息
export const getHistory = () => {
  const result = localStorage.getItem(HISTORY_KEY)
  return result ? JSON.parse(result) : []
}

// 修改信息
export const setHistory = (str) => {
  localStorage.setItem(HISTORY_KEY, JSON.stringify(str))
}
